import React from 'react'
import ProcessRun from '.'
import useModal from '@/hooks/UseModal'

function ProcessRunModal({
  children,
  processId,
  versionId,
  title = '流程试跑',
  initContentLoader,
  processLogId,
  shardingKey,
}) {
  const { hideModal, showModal, visible, data } = useModal()

  return (
    <>
      {React.cloneElement(children, { onClick: () => showModal({ processId, versionId }) })}
      {visible && (
        <ProcessRun
          processLogId={processLogId}
          data={data}
          title={title}
          visible={visible}
          onCancel={hideModal}
          shardingKey={shardingKey}
          initContentLoader={initContentLoader}
        />
      )}
    </>
  )
}

export default ProcessRunModal
